package org.kymjs.example.fragment;

import java.io.File;
import java.io.FileNotFoundException;

import org.kymjs.aframe.KJLoger;
import org.kymjs.aframe.http.HttpCallBack;
import org.kymjs.aframe.http.KJFrameHttp;
import org.kymjs.aframe.http.KJPostParams;
import org.kymjs.aframe.ui.fragment.BaseFragment;
import org.kymjs.example.R;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

public class ExampleFragment extends BaseFragment {

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container,
            Bundle bundle) {
        LinearLayout view = (LinearLayout) inflater.inflate(
                R.layout.example_layout, null);
        return view;
    }

    @Override
    protected void initWidget(View parentView) {
        super.initWidget(parentView);
        hello();
    }

    private void hello() {
        KJFrameHttp kh = new KJFrameHttp();
        KJPostParams params = new KJPostParams();
        params.put("id", "21");
        try {
            params.put("Head_Url", new File("/storage/sdcard0/1.png"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        kh.urlPost(
                "http://192.168.1.222/yili/index.php/umessage/update_message/",
                params, new HttpCallBack<Object>() {
                    @Override
                    public void onSuccess(Object t) {
                        super.onSuccess(t);
                        KJLoger.debug("===========" + t);
                    }

                    @Override
                    public void onFailure(Throwable t, int errorNo,
                            String strMsg) {
                        super.onFailure(t, errorNo, strMsg);
                        KJLoger.debug("=======onFailure====" + t);
                    }
                });
    }
}
